//
//  Presenter.m
//  构架模式MVP
//
//  Created by XHJ on 2020/8/28.
//  Copyright © 2020 L. All rights reserved.
//

#import "Presenter.h"

@implementation Presenter {
    NSArray *_array;
}
- (instancetype)init {
    self = [super init];
    if (self) {
        _array = [NSArray array];
    }
    return self;
}
- (void)load {
    NSArray *result = @[@{@"name":@"Tom",
      @"age":@25,
      @"addr":@"GuangZhou",
      @"gender":@"male",
      },
    @{@"name":@"Jerry",
      @"age":@22,
      @"addr":@"Hangzhou",
      @"gender":@"male",
      },
    @{@"name":@"Lucy",
      @"age":@25,
      @"addr":@"Didu",
      @"gender":@"female",
      }];
    _array = result;
    if ([self.protocol respondsToSelector:@selector(didSelected:)]) {
        [self.protocol didSelected:result];
    }
//    success(result);
}
- (void)attachView:(id<MVPProtocol>)view {
    self.protocol = view;
}
- (void)getOne {
    if ([self.protocol respondsToSelector:@selector(didSelected:)]) {
        [self.protocol didSelected:_array.firstObject];
    }
}
@end
